#include "enterpassword.h"
#include "ui_enterpassword.h"
#include "viewlock.h"

enterpassword::enterpassword(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::enterpassword)
{
    ui->setupUi(this);
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->confirmButton->setShortcut(Qt::Key_Return);
}

enterpassword::~enterpassword()
{
    delete ui;
}

void enterpassword::on_backButton_clicked()
{
    this->close();
    emit back_main_signal();
}

void enterpassword::on_confirmButton_clicked()
{
    this->hide();
    QString password = ui->lineEdit->text();
    viewlock *p_viewlock = new viewlock(password);
    connect(p_viewlock, SIGNAL(back_password_signal()), this, SLOT(reshow()));
    p_viewlock->show();
}

void enterpassword::reshow()
{
    this->show();
}

void enterpassword::on_radioButton_clicked(bool checked)
{
    if (!checked)
    {
        ui->lineEdit->setEchoMode(QLineEdit::Password);
    }
    else
    {
        ui->lineEdit->setEchoMode(QLineEdit::Normal);
    }
}
